package com.viish.android.apps.buildbot.job;

/* Android Buildbot Manager
 Copyright (C) 2011  Sylvain "Viish" Berfini

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.util.List;

import org.json.JSONObject;

public class Slave
{
	private String			name;
	private String			admin;
	private String			access_uri;
	private List<String>	buildersName;
	private boolean			connected;
	private String			host;
	private String			version;

	public Slave(String name, String admin, String access_uri,
			List<String> buildersName, boolean connected, String host,
			String version)
	{
		super();
		this.name = name;
		this.admin = admin;
		this.access_uri = access_uri;
		this.buildersName = buildersName;
		this.connected = connected;
		this.host = host;
		this.version = version;
	}

	public Slave()
	{
		super();
	}

	// TODO : builders
	public Slave(JSONObject jsono)
	{
		super();
		this.name = jsono.optString("name", null);
		this.access_uri = jsono.optString("access_uri", null);
		this.admin = jsono.optString("admin", null);
		this.admin = this.admin.replace("\n", "");
		this.connected = jsono.optBoolean("connected", false);
		this.host = jsono.optString("host", null);
		this.host = this.host.replace("\n", "");
		this.version = jsono.optString("version", null);
	}

	public String toString()
	{
		return "\"" + name + "\": { " + "\"access_uri\": \"" + access_uri
				+ "\", " + "\"admin\": " + admin + ", " + "\"connected\": "
				+ connected + ", " + "\"host\": " + host + ", "
				+ "\"version\": " + version + " }";
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getAdmin()
	{
		return admin;
	}

	public void setAdmin(String admin)
	{
		this.admin = admin;
	}

	public List<String> getBuildersName()
	{
		return buildersName;
	}

	public void setBuildersName(List<String> buildersName)
	{
		this.buildersName = buildersName;
	}

	public boolean isConnected()
	{
		return connected;
	}

	public void setConnected(boolean connected)
	{
		this.connected = connected;
	}

	public String getHost()
	{
		return host;
	}

	public void setHost(String host)
	{
		this.host = host;
	}

	public String getVersion()
	{
		return version;
	}

	public void setVersion(String version)
	{
		this.version = version;
	}

	public String getAccess_uri()
	{
		return access_uri;
	}

	public void setAccess_uri(String accessUri)
	{
		access_uri = accessUri;
	}
}
